import Vue from 'vue'
import Vuex from 'vuex'
// 引入挂载vuex
Vue.use(Vuex)

// 创建vuex实例对象
const store = new Vuex.Store({
    state: {
        count: 1
    },
    getters: {
        getCount(state) {
            return state.count + 1
        }
    },
    mutations: {
        add(state) {
            console.log(state);

            state.count++
        },
        reducation(state) {
            state.count--
        }
    },
    actions: {
        jiajia(context) {
            console.log(context);

            context.commit('add')
        },
        jianjian(context) {
            context.commit('reducation')
        }
    }
})

// 向外导出store
export default store